﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace devicesDll
{
    public class Device
    {
        #region Variables
        protected IPAddress ip;
        protected string[] port;
        protected string[] mac;
        protected long vlan;
        protected bool connectionFailed = false;
        protected int timeout = 1000;
        protected List<CustomResult> customResults = new List<CustomResult>();
        #endregion

        #region Constructor
        public Device(string macAddress, IPAddress ip, string port)
        {
            this.mac = new string[1];
            this.mac[0] = macAddress;
            this.ip = ip;
            this.port = new string[1];
            this.port[0] = port;
        }
        public Device(string macAddress, IPAddress ip, string port, bool connectionFailed)
        {
            this.mac = new string[1];
            this.mac[0] = macAddress;
            this.ip = ip;
            this.port = new string[1];
            this.port[0] = port;
            this.connectionFailed = connectionFailed;
        }

        public Device(string macAddress)
        {
            throw new System.NotImplementedException();
        }

        public Device(IPAddress ip, Int64 vlan)
        {
            throw new System.NotImplementedException();
        }

        public Device()
        {
           
        }
        #endregion

        #region Properties
        public IPAddress IP { get { return ip; } set { ip = value; } }

        public string[] Mac { get { return mac; } set { mac = value; } }

        public bool ConnectionFailed { get { return connectionFailed; } }

        public int Timeout { get { return timeout; } set { timeout = value; } }

        public string[] Port
        {
            get
            {
                return port;
            }
            set
            {
                port = value;
            }
        }

        public long Vlan
        {
            get
            {
                return vlan;
            }
            set
            {
                vlan = value;
            }
        }

        public CustomResult[] CustomResults
        {
            get
            {
                CustomResult[] tmpRet = customResults.ToArray();
                customResults.Clear();
                return tmpRet;
            }
        }
        #endregion

        #region Methods
        public virtual void Query(bool switchOnly, string query)
        {
        }

        public override string ToString()
        {
            string ipstr;
            if (this.ip == null)
                ipstr = "null";
            else
                ipstr = this.ip.ToString();
            return "Device\n IP: " + ipstr + "\n Mac: " + this.mac[0] + "\n";
        }
        #endregion
    }
}
